<#escape x as x?html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
    <TITLE>学生导入</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/resources/css/easyui.css">
    <link rel="stylesheet" type="text/css" href="${rc.contextPath}/resources/css/icon.css">
    <script type="text/javascript" src="${rc.contextPath}/resources/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/resources/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/resources/js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/resources/js/share.js"></script>
    <script type="text/javascript" src="${rc.contextPath}/resources/js/jquery.json-2.4.js"></script>
    <script type="text/javascript">
    	$(function() {
		    $('#p').hide();
    	});
    	function submit() {
			var url = "student/exportStudents";
		    $('#fileupload').form({
		        url:url,
                error: function (jqXHR, textStatus, errorThrown) {
                    $.messager.alert("操作提示", "数据保存异常:[" + jqXHR.statusText + "]", "error");
                },
		        success:function(data){
		    		$('#p').hide();
		    		var jsData = $.evalJSON(data);
		    		$('#totalCount').append(jsData.recordCount);
		    		$('#sucessCount').append(jsData.sucessCount);
		    		var vi = jsData.validInfo;
		    		if (vi != undefined && vi != null) {
		    			$.each(vi, function(i, item) {
		    				$('#validErrors').append('<tr><th width="15%" scope="row">&nbsp;</th><td width="85%">' + item + '</td></tr>');
		    			});
		    		}
		    		var fi = jsData.failInfo;
		    		if (fi != undefined && fi != null) {
		    			$.each(fi, function(i, item) {
		    				$('#saveErrors').append('<tr><th width="15%" scope="row">&nbsp;</th><td width="85%">' + item + '</td></tr>');
		    			});
		    		}
		    		//$('#saveErrors').append(jsData.failInfo);
	                //$.messager.alert("提示", "导入完成！\n" + data, 'info', function() {
                    //	window.parent.closeImportStudentsDialog();
	                //});
		        }
		    });
		    $('#fileupload').submit();
		    $('#p').show();
    	}
    	
		function uploadfile() {
			var filepath=$("input[name='file']").val();  
			if(filepath==undefined || $.trim(filepath) == ""){  
		        $.messager.alert("操作提示", "请首先选择文件！", 'warning');
			}else{  
				var fileArr=filepath.split("//");  
				var fileTArr=fileArr[fileArr.length-1].toLowerCase().split(".");  
				var filetype=fileTArr[fileTArr.length-1];  
				if(filetype != "xls" && filetype != "xlsx"){  
			        $.messager.alert("操作提示", "上传文件必须为Excel文件！", 'warning');
				} else {
					submit();
				}
			}
			
		}
    </script>
</HEAD>
<body>
<form id="fileupload" method="POST" enctype="multipart/form-data">
	<table width="100%" style="font:'宋体';font-size:12px;border-bottom-color:#990000;border-bottom-style:solid;border-top-color:#990000;border-top-style:solid;text-align:center;">
		<tr>
			<td width="60%" style="padding:5 10 4"><input id="file" type="file" name="file"/>&nbsp;</td>
			<td width="40%"><a class="easyui-linkbutton" onclick="uploadfile();">&nbsp;开始导入</a></td>
		</tr>
	</table>
	<p id="p" style="font-family:黑体;font-size:16px;color:red;font-weight:bold;">正在导入，请稍后...</p>
	<table width="100%" style="font:黑体;font-size:12px;border-bottom-color:#66CC66;border-bottom-width:10px;">
		<tr>
			<th width="15%" scope="row" style="font-size:13px">概括</th>
			<td width="85%">共&nbsp;<span id="totalCount"></span>&nbsp;条记录&nbsp;&nbsp;成功导入&nbsp;<span id="sucessCount"></span>&nbsp;条纪录</td>
		</tr>
	</table>
	<table id="validErrors" width="100%" style="font:'黑体';font-size:12px">
		<tr>
			<th width="15%" scope="row" style="font-size:13px">校验错误</th>
			<td width="85%">&nbsp;</td>
		</tr>
	</table>
	<table id="saveErrors" width="100%" style="font:'黑体';font-size:12px">
		<tr>
			<th width="15%" scope="row" style="font-size:13px">保存错误</th>
			<td width="85%">&nbsp;</td>
		</tr>
	</table>
</form>
</body>
</HTML>
</#escape>